<?xml version='1.0' encoding='UTF-8'?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:a="http://java.sun.com/jsf/composite/custom"
	template="../templates/template.xhtml">

	<ui:define name="metadata">
		<!-- FIXME: does work only for GET requests -->
		<f:event type="preRenderView" listener="#{imputationCreationPage.initImputationCreationPage}" />
	</ui:define>

	<ui:define name="pageTitle">#{msg.impImputerTitle}</ui:define>

	<ui:define name="content">
	    <div class="contenu-item">
			<p>
			    #{msg.impImputerPresentation1}
			    <br />
			    #{msg.impImputerPresentation2}
			</p>
	
			<fieldset>
			    <h:panelGrid columns="2" columnClasses="txtGras,">
					<h:outputText value="#{msg.impImputerDate}"/>
					<p:calendar value="#{imputationCreationPage.date}" selectListener="#{imputationCreationPage.dateChanged}"
						    onselectUpdate="consoTooltip" startWeekday="1">
					    <p:tooltip id="consoTooltip">
						<div>
						    <h:outputFormat value="#{msg.impImputerConsoInfo}">
								<f:param value="#{imputationCreationPage.consumateInfo}" />
						    </h:outputFormat>
						</div>
					    </p:tooltip>
					</p:calendar>
		
					<h:outputText value="#{msg.impImputerChoixDates}"/>
					&nbsp;
		
					<h:outputText value="#{msg.impImputerPeriode}" />
					&nbsp;
		
					<h:outputText value="#{msg.dclRechercheDateDu}" />
					<p:calendar value="#{imputationCreationPage.dateFrom}" startWeekday="1"/>
		
					<h:outputText value="#{msg.dclRechercheDateAu}"/>
					<p:calendar value="#{imputationCreationPage.dateTo}" startWeekday="1"/>
		
					<h:outputText value="&nbsp;" escape="false" />
					<h:outputText value="&nbsp;" escape="false" />
		
					<h:outputText value="#{msg.dclRechercheConso}"/>
					<h:selectOneMenu value="#{imputationCreationPage.consumate}">
					    <f:selectItems value="#{imputationCreationPage.consumates}" var="cons"
							   itemLabel="#{cons}" itemValue="#{cons}" />
					</h:selectOneMenu>
		
					<h:outputText value="&nbsp;" escape="false" />
					<h:outputText value="&nbsp;" escape="false" />
		
					<h:outputText value="#{msg.dclRechercheRAF}"/>
					<h:inputText value="#{imputationCreationPage.etc}" required="true">
					    <f:validator validatorId="consumateValidator"/>
					</h:inputText>
		
					<h:outputText value="&nbsp;" escape="false" />
					<h:outputText value="&nbsp;" escape="false" />
		
					<h:outputText value="#{msg.impImputerTacheFinie}"/>
					<h:selectBooleanCheckbox value="#{imputationCreationPage.finished}" />
		
					<h:outputText value="&nbsp;" escape="false" />
					<h:outputText value="&nbsp;" escape="false" />
		
					<h:outputText value="#{msg.impImputerCommentaire}"/>
					<h:inputTextarea value="#{imputationCreationPage.comment}" styleClass="textField"
							 rows="3" cols="25"/>
		
					<h:commandButton action="#{imputationCreationPage.create}" value="#{msg.dclDetailsValider}"
							 styleClass="button"/>
			    </h:panelGrid>
			    <!-- TODO: implement warnNullRaf for the button -->
	
			</fieldset>
	    </div>


	    <div class="contenu-item">
			<fieldset>
			    <h:panelGrid columns="2" columnClasses="txtGras,">
					<h:outputText value="#{msg.tskCreationCode}"/>
					<h:outputText value="#{imputationCreationPage.task.code}" />
		
					<h:outputText value="&nbsp;" escape="false" />
					<h:outputText value="&nbsp;" escape="false" />
		
		
					<h:outputText value="#{msg.tskCreationLibelle}"/>
					<h:outputText value="#{imputationCreationPage.task.label}"/>
		
					<h:outputText value="&nbsp;" escape="false" />
					<h:outputText value="&nbsp;" escape="false" />
		
					<h:outputText value="#{msg.tskCreationCommentaire}"/>
					<h:outputText value="#{imputationCreationPage.task.comment}"/>
		
					<h:outputText value="&nbsp;" escape="false" />
					<h:outputText value="&nbsp;" escape="false" />
		
					<h:outputText value="#{msg.impImputerVendu}"/>
					<h:outputText value="#{imputationCreationPage.task.soldCharge}"/>
		
					<h:outputText value="#{msg.impImputerConsomme}"/>
					<h:outputText value="#{imputationCreationPage.taskConsumate}"/>
		
					<h:outputText value="#{msg.impImputerRAF}"/>
					<h:outputText value="#{imputationCreationPage.taskEtc}"/>
		
					<h:outputText value="&nbsp;" escape="false" />
					<h:outputText value="&nbsp;" escape="false" />
		
					<h:outputText value="#{msg.tskCreationAffectations}"/>
					<ui:repeat value="#{imputationCreationPage.task.assignedEmployees}" var="emp">
					    <li><h:outputText value="#{emp.firstName} #{emp.lastName}"/></li>
					</ui:repeat>
			    </h:panelGrid>
			</fieldset>
	    </div>

	</ui:define>

</ui:composition>